package com.example.onlinemusic.service;

import com.example.onlinemusic.mapper.LoveMusicMapper;
import com.example.onlinemusic.mapper.MusicMapper;
import com.example.onlinemusic.model.Music;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MusicService {
    @Autowired
    private MusicMapper musicMapper;
    @Autowired
    private LoveMusicMapper loveMusicMapper;

    public int insert(String title,String singer,String time,String url,int userid){
        return musicMapper.insert(title, singer, time, url, userid);
    }

    public Integer selectByTitleAndSinger(String title,String singer){
        return musicMapper.selectByTitleAndSinger(title,singer);
    }

    //查询id音乐
    public Music findMusicById(int id){
        return  musicMapper.findMusicById(id);
    }

    //删除id音乐
    public int deleteMusicById(int musicId){
        return  musicMapper.deleteMusicById(musicId);
    }

    //查询所有音乐
    public List<Music> findMusic(){
        return  musicMapper.findMusic();
    }

    public List<Music> findMusicByName(String musicName){
        return  musicMapper.findMusicByName(musicName);
    }

    public int deleteLoveMusicByMusicId(int musicId){
        return loveMusicMapper.deleteLoveMusicByMusicId(musicId);
    }
}
